import axios from "axios";
import { Toast } from "vant";

const instance = axios.create({
  baseURL: "https://api.it120.cc/small4",
});
instance.interceptors.request.use(
  (config) => {
    Toast.loading({
      message: "加载中...",
      forbidClick: true,
      duration: 0,
      //让loading不消失
    });
    return config;
  },
  (err) => {
    return Promise.reject(err);
  }
);
instance.interceptors.response.use(
  (res) => {
    Toast.clear();
    //关闭loading
    return res;
  },
  (err) => {
    return Promise.reject(err);
  }
);

export default instance;
